<?php
include ("global.php");

if($configarray[40]){
 $links=" > User controls";
 $pagetitle=" - User controls";
 include("header.php");
 tableheader1();
 print "<tr><td class=\"tablecell1\"><span class=\"textlarge\">";
 print "<b>Board closed:</b><br>$configarray[40]";
 print "</span></td></tr></table>";
}else{

if(!$user){$user=$useridarray[$navboardlogin];}

$user=(float) $user;
$useridarray[$navboardlogin]=(float) $useridarray[$navboardlogin];

//not logged in || not own profile and not admin || not own profile
if(($user!==$useridarray[$navboardlogin])&&($userloggedinarray[15]!=="administrator")||$login!==1){
 $links=" > Profile > Buddy list";
 $pagetitle=" - Profile - Buddy list";

 include("header.php");
 include("user_header.php");

 echo template('notice',array('notice'=>'You do not have access to this users controls!'));

}else{

$userarray=getdata("$configarray[1]/$user/main.php");

$links=" > Profile > Buddy list > $userarray[0]";
$pagetitle=" - Profile - Buddy list - $userarray[0]";

include("header.php");
include("user_header.php");

 //update account
 if($update==1){

  for($n=0;$n<$configarray[28];$n++){
   $var="buddy$n";
   writedata("$configarray[1]/$user/buddys.php",${$var},$n);
  }

 echo template('notice',array('notice'=>'Buddy list updated'));
 
 echo "<br>";

 //if update is not 1
 }else{

  $userarray=getdata("$configarray[1]/$user/main.php");

  $tplcontent['formheader'].="<form action=\"user_buddy.php\" method=post>";
  $tplcontent['formheader'].="<input type=hidden name=\"update\" value=\"1\">";
  $tplcontent['formheader'].="<input type=hidden name=\"user\" value=\"$user\">";

  $buddyarray=getdata("$configarray[1]/$user/buddys.php");

  $tplcontent['buddymenu'].="<tr>";
  $tplcontent['buddymenu'].="<td class=\"tablecell1\">";
  for($n=0;$n<$configarray[28];$n++){
  	$tplcontent['buddymenu'].="<select name=\"buddy$n\" class=\"forminput\">";
  	$tplcontent['buddymenu'].=usersmenu("$buddyarray[$n]");
  	$tplcontent['buddymenu'].="</select>";
    	if($buddyarray[$n]){
    		$buddyuserarray=getdata("$configarray[1]/$buddyarray[$n]/main.php");
    		$tplcontent['buddymenu'].=" <span class=\"textlarge\">";
    		$tplcontent['buddymenu'].="<b><a href=\"profile.php?user=$buddyarray[$n]\">$buddyuserarray[0]</a></b> ";
    		$tplcontent['buddymenu'].=" Status: ";
     			if(@in_array("$buddyarray[$n]",$onlinearray)){
      				$tplcontent['buddymenu'].="<b><i>! Online !</i></b>";
     			}else{
      				$tplcontent['buddymenu'].="Offline";
     			}
	  		$tplcontent['buddymenu'].="&nbsp;&nbsp;&nbsp;&nbsp;Last Location: ";
	 			if($buddyuserarray[22]){
	  				$tplcontent['buddymenu'].="$buddyuserarray[22]";
	 			}else{
	  				$tplcontent['buddymenu'].="None";
	 			}
	 		$tplcontent['buddymenu'].="</span>";
    	}
   $tplcontent['buddymenu'].="<br>";
  }
  $tplcontent['buddymenu'].="</td>";
  $tplcontent['buddymenu'].="</tr>";

  $tplcontent['submitbutton'].="<input type=submit name=\"submit\" value=\"Update\" class=\"formbutton\">";

  $tplcontent['formfooter'].="</form>";
  
  echo template('userbuddy',$tplcontent);
  
 }//update check

}//access check

}

require ("footer.php");
?>